//
//  HJGroupInviteCell.m
//  KaiChat
//
//  Created by lx on 2023/11/14.
//

#import "HJGroupInviteCell.h"
#import "QMUIButton.h"

@interface HJGroupInviteCell()

@property (nonatomic, weak) UIImageView *avatarImageView;
@property (nonatomic, weak) UILabel *nameLabel;

@end

@implementation HJGroupInviteCell

- (void)settingSubView {
    [super settingSubView];
    
    
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    UIImageView *avatarImageView = [UIImageView addToView:self.contentView];
    avatarImageView.addCornerRadius(20);
    avatarImageView.contentMode = UIViewContentModeScaleAspectFill;
    [avatarImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(leftRightMargin);
        make.centerY.offset(0);
        make.width.height.offset(40);
    }];
 
    UILabel *nameLabel = [UILabel lableWithSuperView:self.contentView font:UIFontMediumMake(14) color:UIColor.tj_333333Color title:nil textAlignment:NSTextAlignmentLeft];
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(avatarImageView.mas_right).offset(10);
        make.centerY.offset(0);
    }];

    QMUIButton *confirmButton = [QMUIButton buttonWithSuperView:self.contentView font:UIFontMake(12) color:UIColor.whiteColor title:@"Confirm"];
    confirmButton.addCornerRadius(5);
    confirmButton.backgroundColor = UIColor.tj_mainColor;
    [confirmButton addTarget:self action:@selector(didClickAddButton) forControlEvents:UIControlEventTouchUpInside];
    [confirmButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.inset(leftRightMargin);
        make.centerY.offset(0);
        make.width.offset(72);
        make.height.offset(30);
    }];
 
    _avatarImageView = avatarImageView;
    _nameLabel = nameLabel;
}

- (void)didClickAddButton {
    if (_didClickAgreeButtonBlock) {
        _didClickAgreeButtonBlock();
    }
}

- (void)setModel:(HJGroupInviteModel *)model {
    _model = model;
    
    [_avatarImageView tj_setImageWithURL:model.avatar.URL placeholderImage:[UIImage imageNamed:defaultAvatarName]];
    _nameLabel.text = model.nickname;
}

@end
